/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import bo.Product_BUS;
import com.opensymphony.xwork2.ActionSupport;
import dto.ProductDTO;

/**
 *
 * @author Tam Nguyen
 */
public class AddProductAdminAction extends ActionSupport {
     
    private String product_id;
    private String category_id;
    private String product_name;
    private int unit_price;
    private String descript;
    private double discount;
    private int quantity;
    private String product_status;
    private String ThongBao;

    public String getThongBao() {
        return ThongBao;
    }

    public void setThongBao(String ThongBao) {
        this.ThongBao = ThongBao;
    }
   
    public String getProduct_id() {
        return product_id;
    }

    public void setProduct_id(String product_id) {
        this.product_id = product_id;
    }

    public String getCategory_id() {
        return category_id;
    }

    public void setCategory_id(String category_id) {
        this.category_id = category_id;
    }

    public String getProduct_name() {
        return product_name;
    }

    public void setProduct_name(String product_name) {
        this.product_name = product_name;
    }

    public int getUnit_price() {
        return unit_price;
    }

    public void setUnit_price(int unit_price) {
        this.unit_price = unit_price;
    }

    public String getDescript() {
        return descript;
    }

    public void setDescript(String descript) {
        this.descript = descript;
    }

    public double getDiscount() {
        return discount;
    }

    public void setDiscount(double discount) {
        this.discount = discount;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public String getProduct_status() {
        return product_status;
    }

    public void setProduct_status(String product_status) {
        this.product_status = product_status;
    }
  
    public AddProductAdminAction() {
    }
    
    public String execute() throws Exception {
        ProductDTO pr = new ProductDTO();
        pr.setProduct_id(product_id);
        pr.setCategory_id(category_id);
        pr.setProduct_name(product_name);
        pr.setUnit_price(unit_price);
        pr.setDescript(descript);
        pr.setDiscount(discount);
        pr.setQuantity(quantity);
        pr.setProduct_status(product_status);
        
        Product_BUS bus = new Product_BUS();
        boolean flag = bus.AddProduct(pr);
        if(flag == true)
        {
            ThongBao = "Ok , Them Thanh Cong";
        }
        else
        {
            ThongBao = "That Bai";
        }
        return "success";
        
    }
}
